package dao;

import java.util.HashMap;

import org.w3c.dom.Document;

import utility.Util_Finding;

public class GetSearchKeywordsRecommendationDAO {
	
	public static String getSearchKeywordsRecommendation(String keyword) {
		
		HashMap<String,String> data=new HashMap<String,String>();
		data.put("keywords", keyword);
		
		Document response = Util_Finding.sendRequest("getSearchKeywordsRecommendation.txt", data);
	    
		try {
			String message = response.getElementsByTagName("message").item(0).getChildNodes().item(0).getNodeValue();
			return message;
		} catch (NullPointerException e) {
			String suggestedKeywords = response.getElementsByTagName("keywords").item(0).getChildNodes().item(0).getNodeValue();
			return suggestedKeywords;
		}
		
		
		//if (message==null) {
		//	String suggestedKeywords = response.getElementsByTagName("keywords").item(0).getChildNodes().item(0).getNodeValue();
		//	return suggestedKeywords;
		//} else {
		//	return message;
		//}
	}
	
}
 